import React from "react";
import { Button } from "antd-mobile";
import { throttle } from "lodash";

import "./index.scss";

/**公共按钮，统一添加节流 */
const ComButton = props => {
	const { btnClassName = "" } = props;
	return (
		<div className={`com-button ${props.className || ""}`} style={props.style}>
			<Button
				disabled={props.disabled}
				onClick={throttle(props.onClick, 2000, { trailing: false })}
				className={props.disabled ? `"disabled" ${btnClassName}` : btnClassName}
				style={props.buttonStyle}
			>
				{props.children || props.title}
			</Button>
		</div>
	);
};
export default ComButton;
